﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Configuration;
using System.Xml;

namespace Avatar.BLL
{
    public class UIConfig
    {
        #region 私有变量
        static private readonly string configPath = "~/Config/UIConfig.config";
        static private string _default_style;
        static private string _default_qyimgCount;
        static private string _default_qyvipCount;
        static private string _default_qyCount;
        static private string _default_newsCount;
        static private string _default_qzNewsCount;
        static private string _default_HotJL_Count;
        static private string _default_HotrcCount;
        static private string _default_rcCount;
        static private string _default_urgentCount;
        #endregion

        #region 属性
        /// <summary>
        /// CSS地址
        /// </summary>
        public string default_style
        {
            get { return _default_style; }
        }
        /// <summary>
        /// 主页企业图片招聘显示数量
        /// </summary>
        public string default_qyimgCount
        {
            get
            {
                return _default_qyimgCount;
            }
        }
        /// <summary>
        /// 主页知名企业显示数量
        /// </summary>
        public string default_qyvipCount
        {
            get
            {
                return _default_qyvipCount;
            }
        }
        /// <summary>
        /// 主页一般企业显示数量
        /// </summary>
        public string default_qyCount
        {
            get
            {
                return _default_qyCount;
            }
        }
        /// <summary>
        /// 主页新闻显示数量
        /// </summary>
        public string default_newsCount
        {
            get
            {
                return _default_newsCount;
            }
        }
        /// <summary>
        /// 主页求职信息栏目显示数量
        /// </summary>
        public string default_qzNewsCount
        {
            get { return _default_qzNewsCount; }
        }
        /// <summary>
        /// 主页推荐简历显示数量
        /// </summary>
        public string default_HotJL_Count
        {
            get { return _default_HotJL_Count; }
        }
        /// <summary>
        /// 主页推荐人才显示数量
        /// </summary>
        public string default_HotrcCount
        {
            get
            {
                return _default_HotrcCount;
            }
        }
        /// <summary>
        /// 主页最新求职信息
        /// </summary>
        public string default_rcCount
        {
            get
            {
                return _default_rcCount;
            }
        }
        /// <summary>
        /// 主页紧急招聘数量
        /// </summary>
        public string default_urgentCount
        {
            get
            {
                return _default_urgentCount;
            }
        }
        #endregion

        /// <summary>
        /// UIConfig构造方法
        /// </summary>
        public UIConfig()
        {
            readUIXML();
        }

        /// <summary>
        /// 执行并读取UICOnfig.Config文件里的value。
        /// </summary>
        public void readUIXML()
        {
            string xmlPath = HttpContext.Current.Server.MapPath(configPath);
            XmlDocument xml = new XmlDocument();
            xml.Load(xmlPath);

            // 取得单个节点appSettings/add里的value
            _default_style = xml.SelectSingleNode("configuration/appSettings/add[@key='default_style']").Attributes["value"].Value;
            _default_qyimgCount = xml.SelectSingleNode("configuration/appSettings/add[@key='default_qypic_Count']").Attributes["value"].Value;
            _default_qyvipCount = xml.SelectSingleNode("configuration/appSettings/add[@key='default_qyvip_Count']").Attributes["value"].Value;
            _default_qyCount = xml.SelectSingleNode("configuration/appSettings/add[@key='default_qy_Count']").Attributes["value"].Value;
            _default_newsCount = xml.SelectSingleNode("configuration/appSettings/add[@key='default_News_Count']").Attributes["value"].Value;
            _default_qzNewsCount = xml.SelectSingleNode("configuration/appSettings/add[@key='default_qzNews_Count']").Attributes["value"].Value;
            _default_HotJL_Count = xml.SelectSingleNode("configuration/appSettings/add[@key='default_HotJL_Count']").Attributes["value"].Value;
            _default_HotrcCount = xml.SelectSingleNode("configuration/appSettings/add[@key='default_Hotrc_Count']").Attributes["value"].Value;
            _default_rcCount = xml.SelectSingleNode("configuration/appSettings/add[@key='default_rc_Count']").Attributes["value"].Value;
            _default_rcCount = xml.SelectSingleNode("configuration/appSettings/add[@key='default_rc_Count']").Attributes["value"].Value;
            _default_urgentCount = xml.SelectSingleNode("configuration/appSettings/add[@key='default_urgent_Count']").Attributes["value"].Value;
        }
    }
}